export function query(name: string) {
  const cache: Map<string, object> =
    (query as any).cache || ((query as any).cache = new Map());
  if (cache.has(name)) {
    console.log('走缓存了');
    return Promise.resolve(cache.get(name));
  }
  return new Promise((resolve, reject) => {
    // 请求接口获取数据
    const result = { username: 'sss' };
    console.log("没走缓存")
    cache.set(name, result);
    resolve(result)
  });
}

query('ss').then(res => {
  console.log(res)
})
setTimeout(() => {
  query('ss').then(res => {
    console.log(res)
  })
}, 1000);

